<?php
/**
 * 输出网站域名
 * 
 * @author seraph.liujb
 */
require_once 'Zend/View/Interface.php';

/**
 * Host helper
 *
 * @uses viewHelper Zend_View_Helper
 */
class Zend_View_Helper_Host {
	
	/**
	 * @var Zend_View_Interface 
	 */
	public $view;
	
	/**
	 * @var string
	 */
	private $_front;
	
	/**
	 * @var string
	 */
	private $_env;
	
	/**
	 * @var string
	 */
	private $_baseUrl;
	
	/**
	 *  输出通用hostname
	 */
	public function host($type = 'www') {
		$this->_front = Zend_Controller_Front::getInstance();
		$this->_baseUrl = $this->_front->getBaseUrl();
		$this->_env = $this->_front->getPlugin('Initializer')->getEnv();
		return $this->$type();
	}
	
	/**
	 * css
	 */
	public function css() {
		return $this->_baseUrl;
	}
	
	/**
	 * js
	 */
	public function js()
	{
		return $this->_baseUrl;
	}
	
	/**
	 * img
	 */
	public function img()
	{
		return $this->_baseUrl;
	}
	
	/**
	 * www 域名
	 */
	public function www() {
		switch ($this->_env){
			case 'dev':
				return 'http://' . $_SERVER['HTTP_HOST'] . $this->_baseUrl;
				break;
			case 'test':
				return 'http://test-seraph-common' . $this->_baseUrl;
				break;
			default:
				return 'http://www-seraph-common' . $this->_baseUrl;
		}
	}
	
	public function __call($name,$arge) {
		return $this->_baseUrl;
	}
	
	/**
	 * Sets the view field 
	 * @param $view Zend_View_Interface
	 */
	public function setView(Zend_View_Interface $view) {
		$this->view = $view;
	}
}
